package org.bluedream.core.module.sys.dao;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;
import org.bluedream.core.module.sys.entity.Organization;
import org.bluedream.core.module.sys.entity.org.OrgRelation;
import java.util.List;


public interface OrganizationDao extends BaseMapper<Organization> {
    Organization selectOne(QueryWrapper<OrgRelation> qw);

    @Select("select a.code as treeCode , a.name as treeName , a.* from sys_organization a order by ${orderByStr}")
    List<Organization> selectAll(@Param("orderByStr")String orderByStr);


    List<Organization> selectListByLoginOrg(@Param("loginOrg_id")String orgCode , @Param("orderByStr")String orderByStr);

    @Select("select a.code as treeCode , a.name as treeName , a.* from sys_organization a where a.id in(select org_id from v_sys_roleAndOrg b where b.id = #{role_id})")
    List<Organization> selectListByRole(@Param("role_id")String roleId , @Param("orderByStr")String orderByStr);
}
